package com.v2.k3;

import com.v2.k1.User;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;


/**
 * 测试BeanFactory，BeanPostProcessor
 */
public class TestBeanFactory {

	public static void main(String[] args) {

		AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition().getBeanDefinition();
		beanDefinition.setBeanClass(User.class);
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

		//注册BeanDefinition
		beanFactory.registerBeanDefinition("uyser", beanDefinition);
		//注册别名
		beanFactory.registerAlias("uyser", "kzx");
		//注册BeanPostProcessor
		beanFactory.addBeanPostProcessor(new TestBeanPostProcessor());

		//获取bean对象
		System.out.println(beanFactory.getBean("kzx"));
//		System.out.println(beanFactory.getBean("uyser"));

	}

}
